<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="vue.js" type="text/javascript"></script>
		<script src="axios.min.js" type="text/javascript"></script>
	</head>
	<body>
		<div id="app">
			<h1>管理员登录</h1>
			用户名:<input v-model="adminName" />
			<br>
			密码:<input v-model="adminPassword" />
			<br>
			<button v-on:click="login">登录</button>
		</div>
	</body>
	<script>
		var config={
			el:"#app",
			data:{
				adminName:null,
				adminPassword:null
			},
			methods:{
				login:function(){
					debugger;
					var serverUrl="http://localhost:1314/admin/login?"
					+"adminName="+this.adminName
					+"&adminPassword="+this.adminPassword;
					//在浏览器中测试url
					console.log(serverUrl);
					axios.get(serverUrl)
					.then(function(res){
						var admin=res.data;
						if (admin.adminId){
							window.alert("管理员登录成功");
							location.href="index.html";
						}
					})
					.catch(function(e){
						window.alert("联网失败");
						console.log(e);
					});
				}
			},
			mounted:function(){
				console.log("mounted()");
			}
		}
		var vue=new Vue(config);
	</script>
</html>



